﻿@model List<DataEntity.SysMenu>

<div class="easyui-layout" data-options="fit:true">

    <div data-options="region:'north',border:false" style="height: auto;">
        <div id="toolbar" class="datagrid-toolbar" style="padding: 8px; border: 0px; border-bottom: #dddddd 1px solid;
            border-collapse: collapse;">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-role',plain:true">
                角色：<b>@ViewBag.RoleName</b></a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          
                
                <a id="asave" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true">
                    保存角色权限</a> 
                <a id="aclear" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-recycle',plain:true">
                    清空角色权限</a> 
                
            
        </div>
    </div>
    <div data-options="region:'center',border:false">
        <div class="easyui-panel" data-options="border:false,fit:true">
            <table class="table_rep" border="0" style="width: 100%;">
                <tr class="hearder" style="background-color: #E7F1FA">
                    <td style="width: 5%; text-align: center;border-left-width:0px;border-top-width:0px;">全选
                    </td>
                    <td style="width: 20%;border-top-width:0px;">模块名称
                    </td>
                    <td style="border-top-width:0px;">权限
                    </td>
                </tr>
                @foreach (var menu in Model)
                {
                    <tr style="text-align: left;">
                        <td style="text-align: center;border-left-width:0px;">
                            <input type="checkbox" name="@menu.SortNumber" onclick="javascript:window.platform.RoleRightManage.checkAll(this,'@menu.ID')" />
                        </td>
                        <td>
                            @{
                    int s = menu.SortNumber.Length / 2;
                    string a = "";
                    for (int i = 0; i < s - 1; i++)
                    {
                        a += "　  ";
                     }
                            }
                            @if (a == "")
                            { 
                                @:&nbsp;@menu.Name
                     }
                            else
                            { 
                                @a @menu.Name
                            }
                        </td>
                        <td>
                          @if(menu.ParentID!=0)
                            {
                          int  roleid = ViewBag.RoleID;
                           var roleright = new DataAccess.DataContext().SysRoleRights.Where(n => n.SysMenuID == menu.ID && n.SysRoleID == roleid).ToList();
                          if(roleright.Count>0)
                          {
                                <input type="checkbox" name="@menu.SortNumber" value="@menu.ID" checked="checked" onclick="javascript:window.platform.RoleRightManage.checkSingle(this)" />@:可访问
                            }
                            else
                            {
                              <input type="checkbox" name="@menu.SortNumber" value="@menu.ID"  onclick="javascript:window.platform.RoleRightManage.checkSingle(this)" />@:可访问
                          
                          }
                          }                                                                                               
                                            
                        </td>
                    </tr>
                }
            </table>
        </div>
    </div>

</div>

<script>
    $(function(){
        window.platform.RoleRightManage.initPage('@ViewBag.RoleID','@ViewBag.RoleName');
    });
</script>